<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%@page isELIgnored="false"%>
<html>
  <head>
  	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/themes/icon.css">
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.min.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/easyui-lang-zh_CN.js"></script>
   	<script type="text/javascript">
	$(function(){
		$('#dialog').dialog({
				iconCls:'icon-save',
			    title: '修改',
			    width: 300,
			    height: 280,
			    closed: true,
			    cache: false,
			    modal: true,
			    buttons:[{
			    	iconCls:'icon-edit',
					text:'更新',
					handler:function(){
						$(document.updateform).submit();
						$('#dialog').dialog("close");
					}
				},{
			    	iconCls:'icon-redo',
					text:'取消',
					handler:function(){
						$('#dialog').dialog("close");
					}
				}]
			 });	
	})
	
	$(function(){
				$(".todos").click(function(){
					var id=$(this).parent().parent().children().eq(0).text();
					$.post("<%=request.getContextPath()%>/new/selectAllById",{"todo.id":id},function(json){
					$("#id").val(json.id);
					$("#name").val(json.name);
					$("#leixing").val(json.leixing);
					$('#dialog').dialog("open");
				});
			});
		})
		
		$(function(){
				$(".deletes").click(function(){
					var id=$(this).parent().parent().children().eq(0).text();
					
					location.href="<%=request.getContextPath()%>/new/deleteTodo?id="+id;
			});
		})
</script>
  </head>
  
  <body>
    <br/>
    	
    	<table  border="1" align="center">
    				
    			<tr>
		    		<td>id</td>
		    		<td>name</td>
		    		<td>leixing</td>
		    		<td></td><td></td>
		    	</tr>
		    		<s:action name="selectAll" namespace="/new" var="cate" >	
					</s:action>
			    	<s:iterator value="#cate.list">
		    	<tr>
		    		<td><s:property value="id"/></td>
		    		<td><s:property value="name"/></td>
		    		<td><s:property value="leixing"/></td>
		    		<td>
						<input class='deletes' type="button" value="删除"/>
					</td>
		    		<td>
		    		   <input class='todos' type="button" value="编辑"/>
		    		</td>
		    	</tr>
		    	
		  		    </s:iterator>
	    </table>
	    <script type="text/javascript">
			function upPage(){
					var pageNo=<s:property value="pageNo"/>	
					var pageSize=<s:property value="pageSize"/>
					if(pageNo==1){
						alert("are you ok?");
						return false;
					}
					location.href="<%=request.getContextPath()%>/new/selectAll?pageNo="+(pageNo-1)+"&pageSize="+pageSize;	
				}
			//下一页
			function downPage(){
					var pageNo=<s:property value="pageNo"/>
					var pageSize=<s:property value="pageSize"/>
					var count=<s:property value="map.page"/>
					if(pageNo==count){
						alert("are you ok?");
						return false;
					}
					location.href="<%=request.getContextPath()%>/new/selectAll?pageNo="+(pageNo+1)+"&pageSize="+pageSize;
			}
			//末页
			function maxPage(){
					var pageSize=<s:property value="pageSize"/>
					var count=<s:property value="map.page"/>
					
					location.href="<%=request.getContextPath()%>/new/selectAll?pageNo="+(count)+"&pageSize="+pageSize;
			}
			
			//首页
			function minPage(){
					var pageSize=<s:property value="pageSize"/>	
					location.href="<%=request.getContextPath()%>/new/selectAll?pageNo=1&pageSize="+pageSize;
			}
		</script>
	    <table border="0" align="center">
	    	<tr>
			    <td><input onclick="minPage()" type="button" value="首页"/></a></td>
			    <td><input onclick="upPage()" type="button" value="上一页"/></td>
			    <td><input onclick="downPage()" type="button" value="下一页"/></a></td>
			    <td><input onclick="maxPage()" type="button" value="末页"/></a></td>
		    </tr>
	    </table>
	    <table border="0" align="center">
	    	<tr>
    			<td><a href="<%=request.getContextPath()%>/jsp/addTodo.jsp"><input type="submit" value="添加"/></a></td>
    		</tr>
    	</table>
  			<div id="dialog">
		 <form action="updateTodo" method="get" name="updateform">
			<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
		    <tr>
		    <td>
			    <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce" align="center" >
			      <tr>
			       	<td width="20%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10"></span></div></td>
			        <td width="60%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10"></span></div></td>
			        <td width="20%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10"></span></div></td>
			      </tr>
			      <tr>
			      	<td height="20" bgcolor="#FFFFFF" class="STYLE6">
			      		<div align="center">
			      			<span class="STYLE19">id</span>
			      		</div>
			      	</td>
			      	<td height="20" bgcolor="#FFFFFF" class="STYLE19" >
			        	<div align="left" >
			        		<input type="text" readonly="readonly" id="id" value="" name="id"/>
			        	</div>
			        </td>
			        <td height="20" bgcolor="#FFFFFF" class="STYLE19">
			        	<div align="center"></div>
			        </td>
			      <tr>
			      	<td height="20" bgcolor="#FFFFFF" class="STYLE6">
			      		<div align="center">
			      			<span class="STYLE19">name</span>
			      		</div>
			      	</td>
			        <td height="20" bgcolor="#FFFFFF" class="STYLE19">
			        	<div align="left">
			        		<input id="name" type="text" name="name" value=""/>
			        	</div>
			        </td>
			        <td height="20" bgcolor="#FFFFFF" class="STYLE19">
			        	<div align="center"></div>
			        </td>
			      </tr>
			     
			      <tr>
			      	<td height="20" bgcolor="#FFFFFF" class="STYLE6">
			      		<div align="center">
			      			<span class="STYLE19">类别</span>
			      		</div>
			      	</td>
			        <td height="20" bgcolor="#FFFFFF" class="STYLE19" >
			        	<div align="left" >
			        		<input type="text" id="leixing" value="" name="leixing"/>
			        	</div>
			        </td>
			        <td height="20" bgcolor="#FFFFFF" class="STYLE19">
			        	<div align="center"></div>
			        </td>  
			    </table>
			 </td>
		  </tr>
		   </table>
		   </form>
   	</div>
   	<div id="dialog1">
   </div>
    	<s:debug></s:debug>
  </body>
</html>
